package com.lsy.weizhi2.customview;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.lsy.weizhi2.R;
import com.zhy.autolayout.AutoRelativeLayout;

/**
 * Created by 嗨哟 on 2016/12/27.
 */
public class Person_Num extends AutoRelativeLayout {
    private TextView person_name,person_num,person_xinzeng;
    private String name,num,xinzeng;
    private Context context;
    public Person_Num(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.person_num,this,true);
        this.context=context;
        TypedArray typedArray=context.obtainStyledAttributes(attrs, R.styleable.Person_Num);
        name=typedArray.getString(R.styleable.Person_Num_personName);
        num=typedArray.getString(R.styleable.Person_Num_personNum);
        xinzeng=typedArray.getString(R.styleable.Person_Num_personXZ);
        typedArray.recycle();
    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        person_name= (TextView) findViewById(R.id.person_name);
        person_num= (TextView) findViewById(R.id.person_num);
        person_xinzeng= (TextView) findViewById(R.id.person_xinzeng);
        if(!TextUtils.isEmpty(name)){
            person_name.setText(name);
        }
        if(!TextUtils.isEmpty(num)){
            person_num.setText(num);
        }
        if(!TextUtils.isEmpty(xinzeng)){
            person_xinzeng.setVisibility(View.VISIBLE);
            person_xinzeng.setText(xinzeng);
        }
    }
    public void setPerson_name(String name){
        person_name.setText(name);
    }
    public void setPerson_num(String num){
        person_num.setText(num);
    }
    public void setPerson_xinzeng(String xinzeng){
        person_xinzeng.setVisibility(View.VISIBLE);
        person_xinzeng.setText(xinzeng);
    }
    public String getNum(){
        return person_num.getText().toString();
    }
    public void setHide(){
        person_xinzeng.setVisibility(View.GONE);
    }
    public void setShow(){
        person_xinzeng.setVisibility(View.VISIBLE);
    }
}
